//
//  DMAdConfig.h
//  DualMediationSDK
//
//  广告配置定义
//

#import <Foundation/Foundation.h>
#import "DMComplianceDelegate.h"

NS_ASSUME_NONNULL_BEGIN

// 前向声明
@class DMUserConsent;

// 回调类型定义
typedef void(^DMConfigUpdateCompletion)(BOOL success, NSError * _Nullable error);

/**
 * 日志级别
 */
typedef NS_ENUM(NSUInteger, DMLogLevel) {
    DMLogLevelVerbose = 0,
    DMLogLevelDebug,
    DMLogLevelInfo,
    DMLogLevelWarning,
    DMLogLevelError
};

/**
 * 广告类型
 */
typedef NS_ENUM(NSUInteger, DMAdType) {
    DMAdTypeBanner = 0,         // 横幅广告
    DMAdTypeInterstitial,       // 插屏广告
    DMAdTypeRewarded,           // 激励视频广告
    DMAdTypeNative,             // 原生广告
    DMAdTypeOfferwall           // 积分墙广告
};

// DMComplianceResult 和 DMComplianceCheckCompletion 已在 DMComplianceDelegate.h 中定义

/**
 * 广告请求
 */
@interface DMAdRequest : NSObject

@property (nonatomic, assign) DMAdType adType;
@property (nonatomic, strong) NSString *adUnitId;
@property (nonatomic, strong) NSString *placement;
@property (nonatomic, strong, nullable) NSDictionary *extraParameters;
@property (nonatomic, assign) BOOL testMode;

- (instancetype)initWithAdType:(DMAdType)adType adUnitId:(NSString *)adUnitId;

@end

/**
 * SDK配置类
 */
@interface DMSDKConfiguration : NSObject

// 基础配置
@property (nonatomic, strong) NSString *appID;
@property (nonatomic, strong) NSString *apiKey;
@property (nonatomic, assign) BOOL enableDebugMode;
@property (nonatomic, assign) BOOL enableLogging;
@property (nonatomic, assign) DMLogLevel logLevel;

// 网络配置
@property (nonatomic, strong) NSString *baseURL;
@property (nonatomic, assign) NSTimeInterval requestTimeout;
@property (nonatomic, assign) NSInteger maxRetryCount;

// 广告配置
@property (nonatomic, assign) BOOL enablePersonalizedAds;
@property (nonatomic, assign) BOOL enableTestMode;
@property (nonatomic, strong) NSArray<NSString *> *testDeviceIDs;

// 合规配置
@property (nonatomic, assign) BOOL enableATTCheck;
@property (nonatomic, assign) BOOL enableGDPRCheck;
@property (nonatomic, assign) BOOL enableCCPACheck;

// 性能配置
@property (nonatomic, assign) NSTimeInterval cacheTimeout;
@property (nonatomic, assign) NSInteger maxCacheSize;

// 新增属性
@property (nonatomic, assign) NSTimeInterval configRefreshInterval;
@property (nonatomic, strong) NSArray<NSString *> *mediationPriority;

// 默认配置
+ (instancetype)defaultConfiguration;
+ (instancetype)debugConfiguration;

@end

/**
 * 广告配置类
 */
@interface DMAdConfig : NSObject

@property (nonatomic, strong) NSString *appId;
@property (nonatomic, strong) NSString *appName;
@property (nonatomic, strong) NSString *sdkVersion;

// SDK Keys
@property (nonatomic, strong, nullable) NSString *maxSDKKey;
// IronSource configuration moved to DMIronSourceAdapter

// 聚合平台配置
@property (nonatomic, strong) NSArray<NSString *> *enabledPlatforms;
@property (nonatomic, strong) NSDictionary<NSString *, NSDictionary *> *platformConfigs;

// 广告单元配置
@property (nonatomic, strong) NSDictionary<NSString *, NSString *> *adUnitIds;

// 广告位映射配置
@property (nonatomic, strong, nullable) NSDictionary<NSString *, NSDictionary *> *placementMappings;

// 测试配置
@property (nonatomic, assign) BOOL testMode;
@property (nonatomic, assign) BOOL debugMode;
@property (nonatomic, strong, nullable) NSArray<NSString *> *testDeviceIds;

// 合规配置
@property (nonatomic, assign) BOOL gdprEnabled;
@property (nonatomic, assign) BOOL ccpaEnabled;
@property (nonatomic, assign) BOOL coppaEnabled;

// EU隐私配置
@property (nonatomic, strong) NSString *isShowEUPrivacy;  // "1" 表示显示EU隐私协议

// 调试模式
@property (nonatomic, assign) BOOL isDebugMode;

// 用户位置信息
@property (nonatomic, strong, nullable) NSString *userProvince;  // 用户所在州/省

// 共享实例
+ (instancetype)sharedConfig;

- (instancetype)initWithAppId:(NSString *)appId;

@end

/**
 * AB测试配置
 */
@interface DMABTestConfig : NSObject

@property (nonatomic, strong) NSString *experimentId;
@property (nonatomic, strong) NSString *variantId;
@property (nonatomic, strong) NSDictionary *parameters;

@end

/**
 * 策略配置
 */
@interface DMStrategyConfig : NSObject

@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) NSDictionary *rules;
@property (nonatomic, assign) NSInteger priority;

@end

/**
 * SDK状态
 */
@interface DMSDKStatus : NSObject

@property (nonatomic, assign) BOOL isInitialized;
@property (nonatomic, strong) NSArray<NSString *> *enabledPlatforms;
@property (nonatomic, strong) NSString *version;
@property (nonatomic, strong, nullable) DMComplianceStatus *complianceStatus;

@end

/**
 * 广告响应
 */
@interface DMAdResponse : NSObject

@property (nonatomic, strong) NSString *platform;
@property (nonatomic, strong) NSString *adUnitId;
@property (nonatomic, assign) double eCPM;
@property (nonatomic, assign) BOOL success;
@property (nonatomic, strong, nullable) NSError *error;
@property (nonatomic, strong, nullable) NSDictionary *adData;
@property (nonatomic, assign) NSTimeInterval responseTime;

- (instancetype)initWithPlatform:(NSString *)platform adUnitId:(NSString *)adUnitId;

@end

NS_ASSUME_NONNULL_END
